package com.dxysun.design.observer;

import com.dxysun.design.observer.api.UserService;
import com.dxysun.design.observer.api.impl.UserServiceImpl;
import com.google.common.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

public class Main
{

    public static void guavaMain() throws Exception
    {
        UserService userService = new UserServiceImpl();
        UserController userController = new UserController();
        userController.setUserService(userService);

        NotificationService notificationService = new NotificationService();
        RegNotificationObserver regNotificationObserver = new RegNotificationObserver();
        regNotificationObserver.setNotificationService(notificationService);

        List<Object> observerList = new ArrayList<>();
        observerList.add(regNotificationObserver);

        userController.setRegObservers(observerList);

        userController.register("123463","5678");

//        System.in.read();
    }

    public static void userGuavaObserver()
    {
        EventBus eventBus = new EventBus();
        eventBus.register(new GuavaObserver());
        eventBus.post("abcd");
    }
    public static void main(String[] args) throws Exception
    {
//        guavaMain();
        userGuavaObserver();
    }
}
